package be.ipl.domaine;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;


/**
 * The Class Jeton.
 */
@SuppressWarnings("serial")
@Entity
@Table(name="Jeton", schema="finito")
public class Jeton implements Serializable {
	
	/** The id_jeton. */
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id_jeton;
	
	/** The nombre. */
	@Column @NotNull @Min(1) @Max(12)
	private int nombre;
	
	/** The pos_tirage. */
	@Column @NotNull @Min(0) @Max(11)
	private int pos_tirage;
	
	/** The partie. */
	@ManyToOne
	@JoinColumn(name="ID_PARTIE")
	private Partie partie;
	
	/**
	 * Instantiates a new jeton.
	 */
	protected Jeton() {
	}
	
	/**
	 * Instantiates a new jeton.
	 *
	 * @param nombre the nombre
	 */
	public Jeton(int nombre) {
		this.nombre = nombre;
	}
	
	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public int getId() {
		return id_jeton;
	}
	
	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(int id) {
		this.id_jeton = id;
	}
	
	/**
	 * Gets the nombre.
	 *
	 * @return the nombre
	 */
	public int getNombre() {
		return nombre;
	}
	
	/**
	 * Sets the nombre.
	 *
	 * @param nombre the new nombre
	 */
	public void setNombre(int nombre) {
		this.nombre = nombre;
	}
	
	/**
	 * Gets the pos_tirage.
	 *
	 * @return the pos_tirage
	 */
	public int getPos_tirage() {
		return pos_tirage;
	}
	
	/**
	 * Sets the pos_tirage.
	 *
	 * @param pos_tirage the new pos_tirage
	 */
	public void setPos_tirage(int pos_tirage) {
		this.pos_tirage = pos_tirage;
	}
	
	/**
	 * Gets the partie.
	 *
	 * @return the partie
	 */
	public Partie getPartie() {
		return partie;
	}
	
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id_jeton;
		return result;
	}
	
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Jeton other = (Jeton) obj;
		if (id_jeton != other.id_jeton)
			return false;
		return true;
	}

	
	
	
	
}
